package com.cndw.kungfu.dao;

import java.util.List;

import com.cndw.dao.jade.Identity;
import com.cndw.dao.jade.annotation.DAO;
import com.cndw.dao.jade.annotation.SQL;
import com.cndw.dao.jade.annotation.SQLParam;

import com.cndw.kungfu.domain.Friend;

@DAO
public interface FriendDao {

	public static final String TABLE = " kf_player_friend ";
	
	public static final String FIELDS = " id,playerId,friendId,friendName,nickName,vocationId,groupId,addTime,lastTalk,intimacy";
	
	
	
	@SQL("select "+FIELDS+" from "+TABLE+" where playerId=:playerId ")
	public List<Friend> select(@SQLParam("playerId") long playerId);
	
	@SQL("INSERT INTO "+TABLE+" ("+FIELDS+") VALUES(:f.id,:f.playerId,:f.friendId,:f.friendName,:f.nickName,:f.vocationId,:f.groupId,:f.addTime,:f.lastTalk,:f.intimacy) ")
	public Identity insert(@SQLParam("f") Friend friend);

	@SQL("delete from "+TABLE+" where playerId=:1 and friendId=:2 ")
	public void delete(long playerId, long friendId);

	@SQL("update "+TABLE+" set friendName=:f.friendName,nickName=:f.nickName,groupId=:f.groupId,lastTalk=:f.lastTalk,intimacy=:f.intimacy where id=:f.id ")
	public void update(@SQLParam("f") Friend friend);

	@SQL("update "+TABLE+" set friendName=:2 where friendId=:1 ")
	public void updateName(long frindeId, String nameNew);

	
	
}
